package com.cws.project.cws.signin.service.impl;

import java.util.Date;
import java.util.List;

import com.cws.common.utils.DateUtils;
import com.cws.common.utils.text.Convert;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.cws.project.cws.signin.mapper.SignInMapper;
import com.cws.project.cws.signin.domain.SignIn;
import com.cws.project.cws.signin.service.ISignInService;

/**
 * 签到管理Service业务层处理
 *
 * @author xyl
 * @date 2022-03-27
 */
@Service
public class SignInServiceImpl implements ISignInService {
    @Autowired
    private SignInMapper signInMapper;

    /**
     * 查询签到管理
     *
     * @param signInId 签到管理ID
     * @return 签到管理
     */
    @Override
    public SignIn selectSignInById(Long signInId) {
        return signInMapper.selectSignInById(signInId);
    }

    /**
     * 查询签到管理列表
     *
     * @param signIn 签到管理
     * @return 签到管理
     */
    @Override
    public List<SignIn> selectSignInList(SignIn signIn) {
        return signInMapper.selectSignInList(signIn);
    }

    /**
     * 新增签到管理
     *
     * @param signIn 签到管理
     * @return 结果
     */
    @Override
    public int insertSignIn(SignIn signIn) {
        signIn.setCreateTime(DateUtils.getNowDate());
        signIn.setStartTime(DateUtils.getNowDate());
        return signInMapper.insertSignIn(signIn);
    }

    /**
     * 修改签到管理
     *
     * @param signIn 签到管理
     * @return 结果
     */
    @Override
    public int updateSignIn(SignIn signIn) {
        signIn.setUpdateTime(DateUtils.getNowDate());
        signIn.setStartTime(DateUtils.getNowDate());
        return signInMapper.updateSignIn(signIn);
    }

    /**
     * 删除签到管理对象
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteSignInByIds(String ids) {
        return signInMapper.deleteSignInByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除签到管理信息
     *
     * @param signInId 签到管理ID
     * @return 结果
     */
    @Override
    public int deleteSignInById(Long signInId) {
        return signInMapper.deleteSignInById(signInId);
    }

    @Override
    public SignIn selectSignInNow(Long courseId) {
        return signInMapper.selectSignInNow(courseId);
    }

    @Override
    public SignIn selectSignInConform(Long courseId, Date signInTime) {
        return signInMapper.selectSignInConform(courseId,signInTime);
    }
}
